package com.chinamsp.codegen;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

import com.chinamsp.codegen.convert.BaseCodeGenProcessor;
import com.chinamsp.codegen.convert.CodeGenContext;

/**
 * 自动生成代码 的 服务
 * @author shifenghu
 *
 */
public class CodeGenService {

	@Autowired
	private CodeGenProperties codeGenProperties;
	
	@Autowired
	private ApplicationContext applicationContext;
	
	/**
	 * 开始 生成 特定类型的代码
	 * @param type  代码类型， 具体见 CodeGenProcessorMapping
	 * @see CodeGenProcessorMapping
	 */
	public void build(CodeGenProcessorMapping type) {
		BaseCodeGenProcessor processor = applicationContext.getBean(type.getProcessorClass());
		processor.build(new CodeGenContext(codeGenProperties.getOutputPath()));
	}
	
	
}
